﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.BackgroundColor = ConsoleColor.DarkBlue;
            Console.Clear();
            Console.ForegroundColor = ConsoleColor.Yellow;
            //Console.BackgroundColor = ConsoleColor.DarkGreen;

            string[] array = { "Add","Edit","Delete","List","Exit"};
            int i;
            int j = 10;

            int index=0;

            do
            {
                /****************************************/
                



                    /****************************************/



                    for (i = 0; i < array.Length; i++)
                    {
                        if (i != index)
                        {
                            j = Menubutton(array, i, j, ConsoleColor.DarkGreen);
                        }

                        else
                        {
                            j = Menubutton(array, i, j, ConsoleColor.DarkGray);
                        }
                    }
                    ConsoleKeyInfo key = Console.ReadKey();

                    if (key.Key == ConsoleKey.DownArrow)
                    {
                        index ++;
                        j = 10; if (index > 4) {index = 4;}
 
                    }
                   if 
                        (key.Key == ConsoleKey.UpArrow)
                    {
                        index --;
                        j = 10; if (index < 0) {index=0;}
                    }


            } 
            while (true);
            
        }

       

                                private static int Menubutton(string[] array, int i, int j, ConsoleColor color)
                                {
                                            Console.BackgroundColor = color;

                                            int n = 20 / 2;
                                            string str = array[i];
                                            int l = str.Length;
                                            int Rn = str.Length / 2;
                                            int fst = 0;
                                            if (str.Length % 2 > 0)
                                                    {
                                                        fst = n - Rn - 1;
                                                    }
                                            else
                                                    {
                                                        fst = n - Rn;
                                                    }
                                            int fnsh = n - Rn;


                                            Console.SetCursorPosition(28, j);
                                            for (int k = 0; k < 20; k++)
                                                    {
                                                        Console.Write(" ");

                                                    }
                                            j++;
                                            Console.SetCursorPosition(28, j);
                                            for (int k = 0; k < fst; k++)
                                                    {

                                                        Console.Write(" ");
                                                    }

                                            Console.Write("{0}", array[i]);

                                            for (int k = 0; k < fnsh; k++)
                                                    {
                                                        Console.Write(" ");

                                                    }
                                            j++;
                                            Console.SetCursorPosition(28, j);
                                            for (int k = 0; k < 20; k++)
                                                    {
                                                        Console.Write(" ");

                                                    }

                                            j++;
                                            return j;
                                   }






           }
        }
      
   
 
